# -*- coding: utf-8 -*-
from PyQt4 import QtCore , QtGui
from lib.customUI import customUI
from lib.papyDB import papyDB , tableInfo
from lib.papyDBTable import *
import os



class assetPublish_UI(customUI):
    def __init__( self , parent=None ):
        QtGui.QMainWindow.__init__(self , parent)
        customUI.__init__(self)



    def createPrjSeqShot(self):
        self.prj_grp , self.prj_cb =  self.grpCBox("Project")
        prjList = PROJECT.search('prjCodeName')
        map(lambda x:self.prj_cb.addItem(x) , prjList ) 
        self.seq_grp , self.seq_cb =  self.grpCBox("Sequence")
        self.shot_grp , self.shot_cb =  self.grpCBox("Shot")  
        self.asset_grp , self.asset_cb = self.grpCBox("Asset")
        
        self.prj_cb.currentIndexChanged.connect( self.initSeqO )
        self.seq_cb.currentIndexChanged.connect( self.initShotO )
        self.shot_cb.currentIndexChanged.connect( self.initAssetO )
        
        self.pssLayout = QtGui.QHBoxLayout()
        self.pssLayout.addWidget(self.prj_grp)
        self.pssLayout.addWidget(self.seq_grp)
        self.pssLayout.addWidget(self.shot_grp) 
        self.pssLayout.addWidget(self.asset_grp)



    def initSeqO(self):        
        self.initSeq('--Master--')
        
    def initShotO(self):
        self.initShot('--Global--')     
        
    def initAssetO(self):
        self.initAsset_assetPublish('--------')


    
    def createCancelDoBtn(self):
        self.assetPub_btn , self.cancel_btn = self.cancelDoBtn("Publish Asset")
        
        self.btn_layout = QtGui.QHBoxLayout()    
        self.btn_layout.addWidget(self.cancel_btn)
        self.btn_layout.addWidget(self.assetPub_btn)



    def setUI(self):                     
        self.mainWidget = QtGui.QWidget( )        
        self.createPrjSeqShot()  
        desc_lb = self.label(" [ Comment ] ")
        self.cmmt_txt = self.txtEditor()
        self.cmmt_txt.setFont( self.txtEdtFont )
        self.createCancelDoBtn()  
        mainGridLayout = QtGui.QGridLayout(self.mainWidget)
        mainGridLayout.addLayout( self.pssLayout, 0, 0, 1, 1 )      
        mainGridLayout.addWidget(desc_lb, 1, 0, 1, 1)
        mainGridLayout.addWidget(self.cmmt_txt, 2, 0, 1, 1)
        mainGridLayout.addLayout(self.btn_layout, 3, 0, 1, 1) 
        self.setCentralWidget(self.mainWidget)
        self.setWindowTitle("Asset Publish")
        self.setGeometry(QtCore.QRect(50 , 500 , 600 , 250))
        self.show()
        self.prj_cb.setCurrentIndex(1)
        self.prj_cb.setCurrentIndex(0)
#        self.asset_cb.setCurrentIndex(1)
#        self.asset_cb.setCurrentIndex(0)


        
if __name__ == '__main__':
    import sys    
    app = QtGui.QApplication(sys.argv)
    ui = assetPublish_UI()
    ui.setUI()
    app.exec_()
        
        
        